{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="javascript:;">品牌</a>
  <a><cite>列表</cite></a>
</span>
<div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <div style="color:#FF5722">网站材质设置,产品存入对应的材质id</div>
       
   
        <div class="layui-form">

          <div class="layui-form-item" style='margin-top:20px'>
            <div class="layui-input-inline">
             <a href="{:url('Material/change')}?nav=material-materiallist" class="layui-btn layui-btn-normal layui-btn-sm">添加</a>
            </div>

            <div class="layui-inline">
              <div class="layui-input-inline">
                <input type="text" name='material' class="layui-input" placeholder="请输入材质名称" value="{$data_list['material']}">
              </div>
            </div>
          
            <div class="layui-inline">
              <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="sear()">查询</button>
              <a href="{:url('Material/index')}?nav=material-materiallist" class="layui-btn layui-btn-sm layui-btn-danger">清空</a>
            </div>
          </div>

          <table class="layui-table" id="script_table">
            <thead>
              <tr>
                <th>id</th>
                <th>材质名称</th>
                <th>描述</th>
                <th>创建时间</th>
                <th>状态</th>
                <th>操作</th>
              </tr> 
            </thead>
            <tbody>
              {volist name="data_list['list']" id="data"}
               <tr>
                <td>{$data.id}</td>
                <td>{$data.material}</td>
                <td>{:strip_tags(substr($data['des'],0,200))} <?php if(!empty($data['des'])){?>...<?php } ?></td>
                <td>{$data.create_time}</td>
                <td>{eq name="$data.status" value="1"}正常{else/}已删除{/eq}</td>
                <td>
                  {eq name="$data.status" value="1"}
                   <button type="button" class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$data.id})">删除</button>
                   <a href="{:url('Material/change')}?nav=material-materiallist&id={$data.id}" class="layui-btn layui-btn-xs">编辑</a>
                  {/eq}
                </td>
              </tr>
              {/volist}
              
            </tbody>
          </table>
           {$data_list['list']|raw}
        </div>

      </div>  
    </div>
</div>

{include file="/public/footer" /}

<script>

  function del(id){
    layer.confirm('你确定要删除吗', {
      btn: ['确定','取消'] //按钮
    }, function(){
      layer.load();
      $.post("{:url('Material/del')}",{id:id},function(res){
          if(res.status=='0'){
              layer.closeAll('loading');
              layer.msg(res.msg);
          }
          if(res.status=='1'){
              layer.msg(
              res.msg,{icon: 1,time: 600},
              function(){
                layer.closeAll('loading');
                location.href=location.href;
              });
          }
      })
    });
  }



 /*查询*/
  function sear(){
    var material=$.trim($("input[name='material']").val());

    if(material==''){
        layer.msg('请输入查询条件');
        return false;
    }

    window.location.href="{:url('Material/index')}"+"?nav=nav=material-materiallist&material="+material;  
  }
</script>
